Skip to content

Make serverless hooks work with parallel ToolRunner - #100

Merged
msullivan merged 2 commits into
mainfrom
more-hooks
May 12, 2026
Merged

Make serverless hooks work with parallel ToolRunner#100
msullivan merged 2 commits into
mainfrom
more-hooks

Conversation

@msullivan

Copy link
Copy Markdown
Contributor

This includes the tricky case, where multiple tool calls are launched
and some of them return results and some need hooks.

Approach:

  • Change hook aborts to raise an Exception instead of cancelling the task
  • Callers should handle the exception, probably by creating a
    pending_tool_result that has is_hook_abort=True
  • Agent.run's replay handling gets extended to detect this case
    and merge the tool results into the assistant message for replay.
    (Maybe this new function, _process_interrupted_hooks should just
    be user facing?)

This includes the tricky case, where multiple tool calls are launched
and *some* of them return results and some need hooks.

Approach:
 * Change hook aborts to raise an Exception instead of cancelling the task
 * Callers should handle the exception, probably by creating a
   `pending_tool_result` that has `is_hook_abort=True`
 * `Agent.run`'s replay handling gets extended to detect this case
   and merge the tool results into the assistant message for replay.
   (Maybe this new function, `_process_interrupted_hooks` should just
   be user facing?)
@msullivan
msullivan requested review from 1st1 and anbuzin May 11, 2026 21:52
@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
py-ai Ready Ready Preview, Comment May 12, 2026 0:37am

Request Review

@msullivan
msullivan merged commit 544cf1d into main May 12, 2026
6 checks passed
@msullivan
msullivan deleted the more-hooks branch May 12, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants